package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.common.Result;
import com.amsp.oa.oademo.entity.PerformanceBonusBase;
import com.amsp.oa.oademo.service.PerformanceBonusBaseService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "绩效奖金基数报批")
@RestController
@RequestMapping("/api/performance-bonus-base")
public class PerformanceBonusBaseController {

    @Autowired
    private PerformanceBonusBaseService bonusBaseService;

    @ApiOperation("分页查询")
    @GetMapping("/page")
    public Result<IPage<PerformanceBonusBase>> getPage(
            @ApiParam("当前页") @RequestParam(defaultValue = "1") Integer current,
            @ApiParam("每页大小") @RequestParam(defaultValue = "10") Integer size,
            @ApiParam("工号") @RequestParam(required = false) String employeeId,
            @ApiParam("姓名") @RequestParam(required = false) String name) {
        return Result.ok(bonusBaseService.getPage(current, size, employeeId, name));
    }

    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    public Result<PerformanceBonusBase> getById(@PathVariable Long id) {
        return Result.ok(bonusBaseService.getById(id));
    }

    @ApiOperation("保存或更新")
    @PostMapping("/save")
    public Result<Boolean> saveOrUpdate(@RequestBody @Validated PerformanceBonusBase entity) {
        return Result.ok(bonusBaseService.saveOrUpdate(entity));
    }

    @ApiOperation("删除")
    @DeleteMapping("/{id}")
    public Result<Boolean> removeById(@PathVariable Long id) {
        return Result.ok(bonusBaseService.removeById(id));
    }
} 